#-*- coding: utf-8 -*-
from socket import *
import struct
class TcpClient:
    HOST='127.0.0.1'
    PORT=12345
    BUFSIZ=1024
    ADDR=(HOST,PORT)
    def __init__(self):
        self.client=socket(AF_INET, SOCK_STREAM)
        self.client.connect(self.ADDR)

        while True:
            data=raw_input('>')
            if not data:
                break
            self.client.send(data.encode('utf8'))
            data=self.client.recv(self.BUFSIZ)
            if not data:
                break
            print(str(data).decode('utf8'))
def test():
    bmp='424d360200000000000036000000280000001000000010000000010010000000000000020000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000ffff000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffff0000000000000000000000000000ffff0000000000000000000000000000ffff0000000000000000000000000000ffffffffffffffffffffffffffffffffffff0000000000000000000000000000ffff0000000000000000000000000000ffff0000000000000000000000000000ffffffffffffffffffffffffffffffffffff0000000000000000000000000000ffff0000000000000000000000000000ffff0000000000000000000000000000ffffffffffffffffffffffffffffffffffff00000000000000000000000000000000ffff00000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffff000000000000000000000000ffff0000ffff00000000000000000000ffff000000000000000000000000ffff000000000000ffff000000000000ffff000000000000000000000000000000000000000000000000ffffffffffff0000000000000000000000000000000000000000ffffffffffff000000000000ffffffffffff0000000000000000ffffffffffff000000000000000000000000000000000000ffffffffffff0000'.decode("HEX")
    
    bfType = struct.unpack('2s', bmp[:2])
    bfSize,bfReserved1,bfReserved2,bfOffBits,biSize,biWidth,biHeight,biPlanes,biBitCount,\
    biCompression,biSizeImage,biXPelsPerMeter,biYPelsPerMeter,biClrUsed,biClrImportant = \
    struct.unpack('I2H2I2i2H2I2i2I', bmp[2:54])

    print("bfType:%s" % bfType)
    print("bfSize:%d" % bfSize)
    print("bfReserved1:%d" % bfReserved1)
    print("bfReserved2:%d" % bfReserved2)
    print("bfOffBits:%d" % bfOffBits)
    print("biSize:%d" % biSize)
    print("biWidth:%d" % biWidth)
    print("biHeight:%d" % biHeight)
    print("biPlanes:%d" % biPlanes)
    print("biBitCount:%d" % biBitCount)
    print("biCompression:%d" % biCompression)
    print("biSizeImage:%d" % biSizeImage)
    print("biXPelsPerMeter:%d" % biXPelsPerMeter)
    print("biYPelsPerMeter:%d" % biYPelsPerMeter)
    print("biClrUsed:%d" % biClrUsed)
    print("biClrImportant:%d" % biClrImportant)

if __name__ == '__main__':
    # client=TcpClient() 
    test()